#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N(1e6 + 5);
int n, m, L, V;
vector<pair<int, int> > seg, seg2;
int pre[N];
inline bool in(int x, pair<int, int> y) {return y.first <= x && x <= y.second;}
inline int get(int l, int r) {if (!l) return pre[r]; return pre[r] - pre[l - 1];}
void work(bool debug=0) {
    cin >> n >> m >> L >> V;
    seg.clear(), seg2.clear();
    for (int i = 1; i <= n; i++) {
        int d, v, a;
        cin >> d >> v >> a;
        if (a == 0) {
            if (v > V) seg.push_back({d, L});
        } else if (a < 0) {
            if (v <= V) continue;
            int dd = V * V - v * v;
            dd = -dd, a = -a;
            dd = (dd - 1) / (2 * a);
            seg.push_back({d, min(d + dd, L)});
        } else {
            if (v > V) seg.push_back({d, L});
            else {
                int dd = V * V - v * v;
                dd = dd / (2 * a) + 1;
                if (d + dd <= L) seg.push_back({d + dd, L});
            }
        }
    }
    memset(pre, 0, sizeof pre);
    for (int i = 1, tt; i <= m; i++) cin >> tt, pre[tt] = 1;
    for (int i = 1; i <= L; i++) pre[i] += pre[i - 1];
    for (auto &v: seg) {
        if (get(v.first, v.second) > 0) seg2.push_back({v.second, v.first});
    }
    cout << seg2.size() << ' ';
    sort(seg2.begin(), seg2.end(), greater<pair<int, int> >());
    for (auto &v: seg2) swap(v.first, v.second);
    //if (debug) for (auto &v: seg2) cerr << v.first << ' ' << v.second << '\n';
    int ans = m;
    for (int i = L, j = 0, mm = 1e9; i; i--) {
        if (pre[i] - pre[i - 1] == 1) {
            if (i < mm && j < seg2.size() && in(i, seg2[j])) ans--, mm = 0;
            while (j < seg2.size() && in(i, seg2[j])) mm = max(mm, seg2[j++].first);
        }
    }
    cout << ans << '\n';
}
signed main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin.tie(0), cout.tie(0)->sync_with_stdio(0);
    int T = 0;
    cin >> T;
    for (int i = 1; i <= T; i++) work();
    return 0;
}
